//
//  DataiViewController.m
//  项目二
//
//  Created by rimi on 16/5/19.
//  Copyright © 2016年 objective. All rights reserved.
//

#import "DataiViewController.h"
#define conton @"1111111"
#define degreesToRadians(x) (M_PI*(x)/180.0)
@interface DataiViewController ()
/**UIImageView */
@property(nonatomic,strong)UIImageView *headerImageView;
@end

@implementation DataiViewController
//初始化方法
- (instancetype)init
{
    self = [super init];
    if (self) {
        NSLog(@"%@",NSStringFromSelector(_cmd));
    }
    return self;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self initUIbutton];
    [self initUIimageView];
    [self initUIlabel];
    [self initTextView];
}

- (void)initUIbutton{
    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
    backButton.frame = CRM(20, 100, 80, 40);
    backButton.backgroundColor = [UIColor orangeColor];
    [backButton setTitle:@"返回" forState:UIControlStateNormal];
    [backButton addTarget:self action:@selector(backbuttonT:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backButton];
}

- (void)initUIimageView{
     _headerImageView= [[UIImageView alloc]initWithFrame:CRM(10, 200, 150, 150)];
    /**加载图片*/
    _headerImageView.image = [UIImage imageNamed:@"fruit10"];
    /**设置圆角*/
    _headerImageView.layer.cornerRadius = 70;
    _headerImageView.clipsToBounds = YES;
    
    /**设置图片显示方式*/
//    headerImageView.contentMode = UIViewContentModeScaleToFill;
    
    /**表示想要往x或者y方向移动多少*/
//    headerImageView.transform = CPM(<#x#>, <#y#>);
    
    /**旋转图像*/
//    headerImageView.transform = CGAffineTransformMakeRotation(degreesToRadians(80));
    
    /**缩放图像*/
//    headerImageView.transform = CGAffineTransformMakeScale(<#CGFloat sx#>, <#CGFloat sy#>);
    
    /**设置投影*/
    /**投影颜色*/
    _headerImageView.backgroundColor = [UIColor redColor];
    /**投影透明度*/
    _headerImageView.layer.shadowOpacity = 0.8;
    /**投影偏移量*/
    _headerImageView.layer.shadowOffset = CSM(3, 3);
    /**边框*/
    /**边框颜色*/
    _headerImageView.layer.borderColor = [UIColor redColor].CGColor;
    /**边框宽度*/
    _headerImageView.layer.borderWidth = 2;
    [self.view addSubview:_headerImageView];
    
#pragma mark  播放一系列图片
    /**播放图片  创建一个数组*/
    //    NSMutableArray *imagesArray = [NSMutableArray array];
    //    headerImageView.animationImages = imagesArray;
    //    /**设定所有的图片在多少秒内播放完毕*/
    //    headerImageView.animationDuration = [imagesArray count];
    //    /**不重复播放多少遍，0表示无数遍*/
    //    headerImageView.animationRepeatCount = 0;
    //    /**开始播放*/
    //    [headerImageView startAnimating];

#pragma mark 为图片添加单击事件：
    //    headerImageView.userInteractionEnabled = YES;
    //    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTapT:)];
    //    [headerImageView addGestureRecognizer:singleTap];
    
#pragma mark - 其他设置
//    headerImageView.hidden = YES;    // 隐藏或者显示图片
//    headerImageView.alpha = 0.1;    // 设置透明度
//    headerImageView.highlightedImage = 0; 	// 设置高亮时显示的图片
//   headerImageView.image = 0;	// 设置正常显示的图片
//    [headerImageView sizeToFit];    // 将图片尺寸调整为与内容图片相同

#pragma mark - 创建一个UIImageView对象有五种方法：
//    UIImageView *imageView1 = [[UIImageView alloc] init];
//    UIImageView *imageView2 = [[UIImageView alloc] initWithFrame:(CGRect)];
//    UIImageView *imageView3 = [[UIImageView alloc] initWithImage:(UIImage *)];
//    UIImageView *imageView4 = [[UIImageView alloc] initWithImage:(UIImage *) highlightedImage:(UIImage *)];
//    UIImageView *imageView5 = [[UIImageView alloc] initWithCoder:(NSCoder *)];
}

- (void)initUIlabel{
    UILabel *nameLabel = [[UILabel alloc]initWithFrame:CRM(CGRectGetMaxX(_headerImageView.frame)+20, CGRectGetMinY(_headerImageView.frame), 150, 40)];
    nameLabel.text = @"wewqrsad";
    nameLabel.font = [UIFont systemFontOfSize:18];
    [self.view addSubview:nameLabel];
    
    UILabel *yearlaberl = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_headerImageView.frame) + 20, CGRectGetMinY(_headerImageView.frame) + 50, 150, 20)];
    yearlaberl.text = @"1955 - 2011";
    yearlaberl.font = [UIFont systemFontOfSize:18];
    [self.view addSubview:yearlaberl];
}

-(void)initTextView{
   /**多行文本框*/
    UITextView *contentView = [[UITextView alloc]initWithFrame:CGRectMake(CGRectGetMinX(_headerImageView.frame), CGRectGetMaxY(_headerImageView.frame) + 50, 300, 100)];
    
    /**字体颜色*/
//    contentView.textColor = [UIColor blackColor];
    
    /**字体名字和字体大小*/
//    contentView.font = [UIFont fontWithName:@"111" size:20];
    
    /**背景颜色*/
//    contentView.backgroundColor = [UIColor whiteColor];
    
    /**返回键类型*/
//    contentView.returnKeyType = UIReturnKeyDefault;
    
    /**是否可以拖动*/
//    contentView.scrollEnabled = YES;
    
    /**自适应高度*/
//    contentView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    
    contentView.text = conton;
    /**禁用编辑*/
    contentView.editable = NO;
    [self.view addSubview:contentView];
}
#pragma mark UIImageView
-(void)singleTapT:(UITapGestureRecognizer *)sender{

}
#pragma mark - UIButton
-(void)backbuttonT:(UIButton *)sender{
    [self.presentingViewController dismissViewControllerAnimated:YES completion:nil];
}
@end
